{% load person_filters editor_tags ietf_filters textfilters %}
<!-- [html-validate-disable-block no-inline-style -- FIXME: should style this better] -->
<div id="session{{ session.pk }}"
     class="session {% if not session.group.parent.scheduling_color %}untoggleable-by-parent{% endif %} {% if session.parent_acronym %}parent-{{ session.parent_acronym }}{% endif %} purpose-{{ session.purpose.slug }} {% if session.readonly %}readonly{% endif %} {% if not session.on_agenda %}off-agenda{% endif %}"
     style="width:{{ session.layout_width }}rem;"
     data-duration="{{ session.requested_duration.total_seconds }}"
     {% if session.attendees != None %} data-attendees="{{ session.attendees }}"{% endif %}
     data-type="{{ session.type.slug }}">
    <div class="session-label {% if session.group and session.group.is_bof %}bof-session{% endif %}">
        {{ session.scheduling_label }}
        {% if session.group and session.group.is_bof %}<span class="bof-tag">BOF</span>{% endif %}
    </div>
    <div>
        <span class="requested-duration">{{ session.requested_duration_in_hours|floatformat }}h</span>
        {% if session.attendees != None %}<span class="attendees">&middot; {{ session.attendees }}</span>{% endif %}
        {% if session.comments %}<span class="comments"><i class="bi bi-chat"></i></span>{% endif %}
        {% if session.constraint_hints %}
            <span class="constraints">
                {% for hint, sessions in session.constraint_hints %}
                    <span data-sessions="{{ sessions|join:"," }}">{% constraint_icon_for hint.constraint_name hint.count %}</span>
                {% endfor %}
            </span>
        {% endif %}
        <div class="past-flag">Past</div>
    </div>
    {# the JS uses this to display session information in the bottom panel #}
    <div class="session-info">
        <div class="title">
            <strong>
                <span class="time float-end"></span>
                {{ session.scheduling_label }} &middot; {{ session.requested_duration_in_hours }}h
                {% if session.purpose_label  %}&middot; {{ session.purpose_label }}{% endif %}
                {% if session.attendees != None %}&middot; {{ session.attendees }} <i class="bi bi-person"></i>{% endif %}
            </strong>
        </div>
        {% if session.group %}
            <div>
                <a href="{{ session.group.about_url }}">{{ session.group.name }}</a>
                {% if session.group.parent %}
                    &middot;
                        {% comment %}
                        FIXME-LARS: this breaks the test:
                        <a class="session-parent" href="{{ session.group.parent.about_url }}">{{ session.group.parent.acronym }}</a>
                        {% endcomment %}
                        <span class="session-parent">{{ session.group.parent.acronym }}</span>
                {% endif %}
                {% if not session.on_agenda %}&middot; <i>off agenda</i>{% endif %}
            </div>
        {% endif %}
        {% if session.comments %}<div class="comments">{{ session.comments|urlize_ietf_docs|linkify|linebreaksbr }}</div>{% endif %}
        {% if session.requested_by_person %}
            <div class="row">
                <div class="col-1">
                    <i title="Requested by" class="bi bi-person-circle"></i>
                </div>
                <div class="col">
                    {% person_link session.requested_by_person %}
                    {% if session.requested_time %}({{ session.requested_time|date:"Y-m-d" }}){% endif %}
                </div>
            </div>
        {% endif %}
        {% if session.resources.all %}
            <div class="row">
                <div class="col-1"><i class="bi bi-layers-fill" title="Resources"></i></div>
                <div class="col">
                    {% for r in session.resources.all %}
                        {{ r.name }}{% if not forloop.last %}, {% endif %}
                    {% endfor %}
                </div>
            </div>
        {% endif %}
        {% if session.formatted_constraints %}
            <div class="formatted-constraints">
                {% with ad=session.group.ads|first %}
                {% for constraint_name, values in session.formatted_constraints.items %}
                    <div class="row">
                        <div class="col-1" title="{{ constraint_name.name }}">{% constraint_icon_for constraint_name %}</div><div class="col">
                            {% if constraint_name.slug != 'bethere' or not ad %}
                                {{ values|join:", " }}
                            {% else %}
                                {% for val in values %}
                                    {% if val != ad.person.plain_name %}
                                        {{ val }}{% if forloop.revcounter > 2 or forloop.revcounter > 1 and values|last != ad.person.plain_name %}, {% endif %}
                                    {% endif %}
                                {% endfor %}
                            {% endif %}
                        </div>
                    </div>
                {% endfor %}
                {% endwith %}
            </div>
        {% endif %}
        {% for s in session.other_sessions %}
            <div class="other-session row" data-othersessionid="{{ s.pk }}">
                <div class="col-1">
                    <i class="bi bi-calendar" title="Other session"></i>
                </div>
                <div class="col">
                    <span class="time"
                          data-scheduled="scheduled: {time}"
                          data-notscheduled="not yet scheduled"></span>
               </div>
            </div>
        {% endfor %}
        {% if secretariat %}
            <a class="btn btn-primary btn-sm mt-2"
               href="{% url 'ietf.meeting.views.edit_session' session_id=session.pk %}?sched={{ schedule.pk }}">
                Edit session
            </a>
            <a class="btn btn-danger btn-sm mt-2"
               href="{% url 'ietf.meeting.views.cancel_session' session_id=session.pk %}?sched={{ schedule.pk }}">
                Cancel session
            </a>
        {% endif %}
    </div>
</div>